package com.leo.util;

import java.util.Calendar;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang.StringUtils;
import org.junit.Test;

public class TestUtils {
	/**
	 * 根据日期获取星期几
	 * @param date
	 * @return
	 */
	public static String getWeek(Date date) {
		Integer[] weeks = { 0, 1, 2, 3, 4, 5, 6 };
		Calendar cal = Calendar.getInstance();
		cal.setTime(date);
		int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
		if (week_index < 0) {
			week_index = 0;
		}
		return weeks[week_index].toString();
	}
	/**
	 * main方法
	 * @param args
	 */
	public static void main(String[] args) {
		//System.out.println(Calendar.DAY_OF_WEEK);
		//System.out.println(getWeek(new Date()));
		LinkedList linkedList = new LinkedList();
		Collections.synchronizedList(linkedList);
	}
	
	
	/**
	 * 以13开头的所有的11位的手机号
	 */
	@Test
	public void testRegPhone(){
		Pattern pattern = Pattern.compile("1[358]\\d{9}");
		Matcher matcher = pattern.matcher("16445789658");
		System.out.println(matcher.matches());
	}
	/**
	 * 正则表达式 匹配邮箱
	 * ^[A-Za-z0-9][\\w\\-\\.]{3,12}@([\\w\\-]+\\.)+[\\w]{2,3}$
	 * ^w+{1,*}@[a-z0-9]{1,5}.([a-z]{1,4})*$
	 */
	@Test
	public void testRegMail(){
		Pattern pattern = Pattern.compile("^[A-Za-z0-9][\\w]{3,12}@([\\w]+\\.)+[\\w]{2,3}$");
		Matcher matcher = pattern.matcher("lianliang2014@126.com.cn");
		System.out.println(matcher.matches());
	}
	
	@Test
	public void testCode(){
		String mac = "00:08:22:fc:70:fc";
		String imei = "";
		if (StringUtils.isNotBlank(mac) || StringUtils.isNotBlank(imei)) {
            System.out.println("两者有一个不为空！");
        }else{
        	System.out.println("两者都为空！");
        }
	}
	
}
